package cn.com.headfree.salary.service.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import cn.com.headfree.entity.*;
import cn.com.headfree.entity.isc.User;
import cn.com.headfree.salary.dao.IUserDataInfoDao;
import cn.com.headfree.salary.service.IUserDataInfoService;
import cn.com.headfree.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service("userDataInfoService")
public class UserDataInfoServiceImpl implements IUserDataInfoService {
    @Autowired
    private IUserDataInfoDao userInfoDao;

    /**
     * 基本信息
     *
     * @param erpNo
     * @return
     */
    @Override
    public TEmpBaseInfo getBaseInfoByErpNo(String erpNo) {
        return userInfoDao.getBaseInfoByErpNo(erpNo);
    }


    /**
     * 专业技术资格
     *
     * @param erpNo
     */
    @Override
    public List<ProTecInfoVo> getProTecInfoByErpNo(String erpNo, String salaryId, int year) {
        return userInfoDao.getProTecInfoByErpNo(erpNo, salaryId, year);
    }


    /**
     * 获取专业技术资格
     *
     * @param erpNo
     * @param salaryId
     * @param mouId
     * @param ruleId
     * @param start
     * @param end
     * @return
     */
    @Override
    public List<ProTecInfoVo> getProTecInfoByErpNo(String erpNo, String salaryId, String mouId, String ruleId, String start, String end,String orgId) {
        return userInfoDao.getProTecInfoByErpNo(erpNo, salaryId, mouId, ruleId, start, end,orgId);
    }

    /**
     * 专业技术资格
     *
     * @param erpNo
     */
    @Override
    public List<ProTecInfoVo> getProTecInfoByErpNo(String erpNo, String salaryId, String mouId, String ruleId, int year,String orgId) {
        return userInfoDao.getProTecInfoByErpNo(erpNo, salaryId, mouId, ruleId, year,orgId);
    }

    @Override
    public List<ProTecInfoVo> getProTecInfoByErpNoInSalary(String erpNo, String salaryId, String mouId, String ruleId, int year,String orgId,String businessTypeId) {
        return userInfoDao.getProTecInfoByErpNoInSalary(erpNo, salaryId, mouId, ruleId, year,orgId,businessTypeId);
    }


    /**
     * 上年度技能等级
     *
     * @param erpNo
     */
    @Override
    public List<SkillLevelInfoVo> getSkillLevelInfoByErpNo(String erpNo, String salaryId, String mouId, String ruleId, int year,String orgId) {
        return userInfoDao.getSkillLevelInfoByErpNo(erpNo, salaryId, mouId, ruleId, year,orgId);
    }

    @Override
    public List<SkillLevelInfoVo> getSkillLevelInfoByErpNoInSalary(String erpNo, String salaryId, String mouId, String ruleId, int year,String orgId ,String businessTypeId) {
        return userInfoDao.getSkillLevelInfoByErpNoInSalary(erpNo, salaryId, mouId, ruleId, year,orgId,businessTypeId);
    }

    /**
     * 全部专业技术资格
     *
     * @param erpNo
     */
    @Override
    public List<ProTecInfoVo> getAllProTecInfoByErpNo(String erpNo, String salaryId) {
        return userInfoDao.getAllProTecInfoByErpNo(erpNo, salaryId);
    }

    /**
     * 上年度技能等级
     *
     * @param erpNo
     */
    @Override
    public List<SkillLevelInfoVo> getSkillLevelInfoByErpNo(String erpNo, String salaryId, int year) {
        return userInfoDao.getSkillLevelInfoByErpNo(erpNo, salaryId, year);
    }


    /**
     * 上年度技能等级，用于积分管理
     *
     * @param erpNo
     */
    @Override
    public List<SkillLevelInfoVo> getSkillLevelInfoByErpNo(String erpNo, String salaryId, String mouId, String ruleId, String start, String end,String orgId) {
        return userInfoDao.getSkillLevelInfoByErpNo(erpNo, salaryId, mouId, ruleId, start, end,orgId);
    }

    /**
     * 全部技能等级
     *
     * @param erpNo
     */
    @Override
    public List<SkillLevelInfoVo> getAllSkillLevelInfoByErpNo(String erpNo, String salaryId) {
        return userInfoDao.getAllSkillLevelInfoByErpNo(erpNo, salaryId);
    }


    /**
     * 专家人才称号
     *
     * @param erpNo
     */
    @Override
    public List<ExpertTitleVo> getExpertTitleInfoByErpNo(String erpNo, String salaryId, int year) {
        return userInfoDao.getExpertTitleInfoByErpNo(erpNo, salaryId, year);
    }

    /**
     * 专家人才称号
     *
     * @param erpNo
     */
    @Override
    public List<ExpertTitleVo> getExpertTitleInfoByErpNo(String erpNo, String salaryId, String mouldId, String ruleId, int year,String orgId) {
        return userInfoDao.getExpertTitleInfoByErpNo(erpNo, salaryId, mouldId, ruleId, year,orgId);
    }

    @Override
    public List<ExpertTitleVo> getExpertTitleInfoByErpNoInSalary(String erpNo, String salaryId, String mouldId, String ruleId, int year,String orgId,String businessTypeId) {
        return userInfoDao.getExpertTitleInfoByErpNoInSalary(erpNo, salaryId, mouldId, ruleId, year,orgId,businessTypeId);
    }

    /**
     * 近5年专家人才称号
     *
     * @param erpNo
     */
    @Override
    public List<ExpertTitleVo> getFiveYearExpertTitleInfoByErpNo(String erpNo, String salaryId, String mouldId, String ruleId, int year,String orgId) {
        return userInfoDao.getFiveYearExpertTitleInfoByErpNo(erpNo, salaryId, mouldId, ruleId, year,orgId);
    }

    /**
     * 全部专家人才称号
     *
     * @param erpNo
     */
    @Override
    public List<ExpertTitleVo> getAllExpertTitleInfoByErpNo(String erpNo, String salaryId) {
        return userInfoDao.getAllExpertTitleInfoByErpNo(erpNo, salaryId);
    }

    /**
     * 学术成果
     *
     * @param erpNo
     */
    @Override
    public List<AcadeAchiveVo> getAcadeAchiveInfoByErpNo(String erpNo, String salaryId, int year) {
        return userInfoDao.getAcadeAchiveInfoByErpNo(erpNo, salaryId, year);
    }

    /**
     * 学术成果
     *
     * @param erpNo
     */
    @Override
    public List<AcadeAchiveVo> getAcadeAchiveInfoByErpNo(String erpNo, String salaryId, String mouldId, String ruleId, int year,String orgId) {
        return userInfoDao.getAcadeAchiveInfoByErpNo(erpNo, salaryId, mouldId, ruleId, year,orgId);
    }

    @Override
    public List<AcadeAchiveVo> getAcadeAchiveInfoByErpNoInSalary(String erpNo, String salaryId, String mouldId, String ruleId, int year,String orgId,String businessTypeId) {
        return userInfoDao.getAcadeAchiveInfoByErpNoInSalary(erpNo, salaryId, mouldId, ruleId, year,orgId,businessTypeId);
    }

    /**
     * 科技创新成果
     *
     * @param erpNo
     */
    @Override
    public List<TecManInnovVo> getTecManInnovByErpNo(String erpNo, String salaryId, int year) {
        return userInfoDao.getTecManInnovByErpNo(erpNo, salaryId, year);
    }

    /**
     * 技艺革新
     *
     * @param erpNo
     */
    @Override
    public List<TecInnovInfoVo> getTecInnovInfoByErpNo(String erpNo, String salaryId, int year) {
        return userInfoDao.getTecInnovInfoByErpNo(erpNo, salaryId, year);
    }

    /**
     * 个人荣誉
     *
     * @param erpNo
     */
    @Override
    public List<HonorDatasVo> getHonnorInfoByErpNo(String erpNo, String salaryId, int year) {
        return userInfoDao.getHonnorInfoByErpNo(erpNo, salaryId, year);
    }

    /**
     * 工作经历
     *
     * @param erpNo
     */
    @Override
    public List<WorkExpInfoVo> getWorkExpInfoByErpNo(String erpNo, String salaryId) {
        return userInfoDao.getWorkExpInfoByErpNo(erpNo, salaryId);
    }

    /**
     * 学历信息
     *
     * @param erpNo
     */
    @Override
    public List<EducateInfoVo> getEducateInfoByErpNo(String erpNo, String salaryId, int year) {
        return userInfoDao.getEducateInfoByErpNo(erpNo, salaryId, year);
    }

    /**
     * 已经提报薪档的学历信息
     * @param erpNo
     * @param salaryId
     * @param year
     * @param businessTypeId
     * @return
     */
    @Override
    public List<EducateInfoVo> getEducateInfoByErpNoInSalary(String erpNo, String salaryId, int year,String businessTypeId) {
        return userInfoDao.getEducateInfoByErpNoInSalary(erpNo, salaryId, year,businessTypeId);
    }



    /**
     * 学历信息,
     * Ant-K新增
     *
     * @param erpNo
     */
    @Override
    public List<EducateInfoVo> getEducateInfoByErpNo(String erpNo, String salaryId, String start, String end) {
        return userInfoDao.getEducateInfoByErpNo(erpNo, salaryId, start, end);
    }

    /**
     * 专利信息
     *
     * @param erpNo
     */
    @Override
    public List<PatentInfoVo> getPatentInfoByErpNo(String erpNo, String salaryId, String mouldId, String ruleId, int year,String orgId) {
        return userInfoDao.getPatentInfoByErpNo(erpNo, salaryId, mouldId, ruleId, year,orgId);
    }

    @Override
    public List<PatentInfoVo> getPatentInfoByErpNoInSalary(String erpNo, String salaryId, String mouldId, String ruleId, int year,String orgId,String businessTypeId) {
        return userInfoDao.getPatentInfoByErpNoInSalary(erpNo, salaryId, mouldId, ruleId, year,orgId,businessTypeId);
    }

    /**
     * 专利信息
     *
     * @param erpNo
     */
    @Override
    public List<PatentInfoVo> getPatentInfoByErpNo(String erpNo, String salaryId, int year) {
        return userInfoDao.getPatentInfoByErpNo(erpNo, salaryId, year);
    }

    /**
     * 竞赛考试
     *
     * @param erpNo
     */
    @Override
    public List<ContestInfoVo> getContestInfoByErpNo(String erpNo, String salaryId, int year) {
        return userInfoDao.getContestInfoByErpNo(erpNo, salaryId, year);
    }

    /**
     * 上一年度绩效
     *
     * @param erpNo
     */
    public List<YearEffectVo> getYearEffectByErpNo(String erpNo, String mouldId, String ruleId, int year,String orgId) {
        return userInfoDao.getYearEffectByErpNo(erpNo, mouldId, ruleId, year,orgId);
    }

    /**
     * 上一年度绩效
     *
     * @param erpNo
     */
    public List<YearEffectVo> getYearEffectByErpNo(String erpNo, int year) {
        return userInfoDao.getYearEffectByErpNo(erpNo, year);
    }

    @Override
    public List<EducateInfoVo> getFullTimeEducateInfoByErpNo(String erpNo) {
        return userInfoDao.getFullTimeEducateInfoByErpNo(erpNo);
    }

    @Override
    public List<EducateInfoVo> getEducateInfoHighEducByErpNo(String erpNo) {
        return userInfoDao.getEducateInfoHighEducByErpNo(erpNo);
    }

    /**
     * 组合各类型ID，以下载附件
     *
     * @param erpNo
     * @return
     */
    @Override
    public List<BusinessIdsVo> getBusinessIdByErpNo(String erpNo, String salaryId, int year) {
        List<BusinessIdsVo> list = new ArrayList<>();
        //基本信息
        TEmpBaseInfo baseInfo = getBaseInfoByErpNo(erpNo);
        if (baseInfo != null) {
            BusinessIdsVo vo = new BusinessIdsVo();
            vo.setBusinessId(baseInfo.getId());
            vo.setTypeName("基本信息");
            list.add(vo);
        }

        //学历
        List<EducateInfoVo> educateInfos = getEducateInfoByErpNo(erpNo, salaryId, year);
        if (educateInfos != null) {
            for (EducateInfoVo studyAndTrainVo : educateInfos) {
                if (studyAndTrainVo.getIsHide() == null || !(studyAndTrainVo.getIsHide().equals("0"))) {
                    BusinessIdsVo vo = new BusinessIdsVo();
                    vo.setBusinessId(studyAndTrainVo.getId());
                    vo.setTypeName("学历信息");
                    list.add(vo);
                }
            }
        }
        //专业技术资格
        List<ProTecInfoVo> proTecInfos = getProTecInfoByErpNo(erpNo, salaryId, year);
        if (proTecInfos != null) {
            for (ProTecInfoVo proTecInfoVo : proTecInfos) {
                if (proTecInfoVo.getIsHide() == null || !(proTecInfoVo.getIsHide().equals("0"))) {
                    BusinessIdsVo vo = new BusinessIdsVo();
                    vo.setBusinessId(proTecInfoVo.getId());
                    vo.setTypeName("专业技术资格");
                    list.add(vo);
                }
            }
        }

        //技能等级
        List<SkillLevelInfoVo> skillLevelInfos = getSkillLevelInfoByErpNo(erpNo, salaryId, year);
        if (skillLevelInfos != null) {
            for (SkillLevelInfoVo skillLevelInfoVo : skillLevelInfos) {
                if (skillLevelInfoVo.getIsHide() == null || !(skillLevelInfoVo.getIsHide().equals("0"))) {
                    BusinessIdsVo vo = new BusinessIdsVo();
                    vo.setBusinessId(skillLevelInfoVo.getId());
                    vo.setTypeName("技能等级");
                    list.add(vo);
                }
            }
        }

        //专家人才称号
        List<ExpertTitleVo> expertTitleInfos = getExpertTitleInfoByErpNo(erpNo, salaryId, year);
        if (expertTitleInfos != null) {
            for (ExpertTitleVo honorDatasVo : expertTitleInfos) {
                if (honorDatasVo.getIsHide() == null || !(honorDatasVo.getIsHide().equals("0"))) {
                    BusinessIdsVo vo = new BusinessIdsVo();
                    vo.setBusinessId(honorDatasVo.getId());
                    vo.setTypeName("专家人才称号");
                    list.add(vo);
                }
            }
        }

        //学术成果
        List<AcadeAchiveVo> acadeAchiveInfos = getAcadeAchiveInfoByErpNo(erpNo, salaryId, year);
        if (acadeAchiveInfos != null) {
            for (AcadeAchiveVo acadeAchiveVo : acadeAchiveInfos) {
                if (acadeAchiveVo.getIsHide() == null || !(acadeAchiveVo.getIsHide().equals("0"))) {
                    BusinessIdsVo vo = new BusinessIdsVo();
                    vo.setBusinessId(acadeAchiveVo.getId());
                    vo.setTypeName("学术成果");
                    list.add(vo);
                }
            }
        }

        //发明专利
        List<PatentInfoVo> patentInfos = getPatentInfoByErpNo(erpNo, salaryId, year);
        if (patentInfos != null) {
            for (PatentInfoVo patentInfoVo : patentInfos) {
                if (patentInfoVo.getIsHide() == null || !(patentInfoVo.getIsHide().equals("0"))) {
                    BusinessIdsVo vo = new BusinessIdsVo();
                    vo.setBusinessId(patentInfoVo.getId());
                    vo.setTypeName("发明专利");
                    list.add(vo);
                }
            }
        }

        //科技创新
        List<TecManInnovVo> tecManInnovs = getTecManInnovByErpNo(erpNo, salaryId, year);
        if (tecManInnovs != null) {
            for (TecManInnovVo tecManInnovVo : tecManInnovs) {
                if (tecManInnovVo.getIsHide() == null || !(tecManInnovVo.getIsHide().equals("0"))) {
                    BusinessIdsVo vo = new BusinessIdsVo();
                    vo.setBusinessId(tecManInnovVo.getId());
                    vo.setTypeName("科技管理创新");
                    list.add(vo);
                }
            }
        }

        //技艺革新
        List<TecInnovInfoVo> tecInnovInfos = getTecInnovInfoByErpNo(erpNo, salaryId, year);
        if (tecInnovInfos != null) {
            for (TecInnovInfoVo tecInnovInfoVo : tecInnovInfos) {
                if (tecInnovInfoVo.getIsHide() == null || !(tecInnovInfoVo.getIsHide().equals("0"))) {
                    BusinessIdsVo vo = new BusinessIdsVo();
                    vo.setBusinessId(tecInnovInfoVo.getId());
                    vo.setTypeName("成果推广应用、群众性管理创新、质量管理创新");
                    list.add(vo);
                }
            }
        }

        //专业竞赛考试
        List<ContestInfoVo> tContestInfos = getContestInfoByErpNo(erpNo, salaryId, year);
        if (tContestInfos != null) {
            for (ContestInfoVo contestInfoVo : tContestInfos) {
                if (contestInfoVo.getIsHide() == null || !(contestInfoVo.getIsHide().equals("0"))) {
                    BusinessIdsVo vo = new BusinessIdsVo();
                    vo.setBusinessId(contestInfoVo.getId());
                    vo.setTypeName("专业竞赛考试");
                    list.add(vo);
                }
            }
        }

        //个人荣誉
        List<HonorDatasVo> honnorInfos = getHonnorInfoByErpNo(erpNo, salaryId, year);
        if (honnorInfos != null) {
            for (HonorDatasVo honorDatasVo : honnorInfos) {
                if (honorDatasVo.getIsHide() == null || !(honorDatasVo.getIsHide().equals("0"))) {
                    BusinessIdsVo vo = new BusinessIdsVo();
                    vo.setBusinessId(honorDatasVo.getId());
                    vo.setTypeName("个人荣誉");
                    list.add(vo);
                }
            }
        }

        //员工流动
        List<TEmployeeMobilityVo> employMobilities = getEmployeeMobilityByErpNo(erpNo, salaryId, year);
        if (employMobilities != null) {
            for (TEmployeeMobilityVo employMobilityVo : employMobilities) {
                if (employMobilityVo.getIsHide() == null || !(employMobilityVo.getIsHide().equals("0"))) {
                    BusinessIdsVo vo = new BusinessIdsVo();
                    vo.setBusinessId(employMobilityVo.getId());
                    vo.setTypeName("员工流动");
                    list.add(vo);
                }
            }
        }
        return list;
    }


    private List<TEmployeeMobilityVo> getEmployeeMobilityByErpNo(String erpNo, String salaryId, int year) {
    	return userInfoDao.getEmployeeMobilityByErpNo(erpNo, salaryId, year);
	}


	@Override
    public List<HonorDatasVo> getHonnorInfoByErpNo(String erpNo, String salaryId, String mouldId, String ruleId, int year,String orgId) {
        return userInfoDao.getHonnorInfoByErpNo(erpNo, salaryId, mouldId, ruleId, year,orgId);
    }

    @Override
    public List<HonorDatasVo> getHonnorInfoByErpNoInSalary(String erpNo, String salaryId, String mouldId, String ruleId, int year,String orgId,String businessTypeId) {
        return userInfoDao.getHonnorInfoByErpNoInSalary(erpNo, salaryId, mouldId, ruleId, year,orgId,businessTypeId);
    }


    @Override
    public List<ContestInfoVo> getContestInfoByErpNo(String erpNo, String salaryId, String mouldId, String ruleId, int year,String orgId) {
        return userInfoDao.getContestInfoByErpNo(erpNo, salaryId, mouldId, ruleId, year,orgId);
    }

    @Override
    public List<ContestInfoVo> getContestInfoByErpNoInSalary(String erpNo, String salaryId, String mouldId, String ruleId, int year,String orgId,String businessTypeId) {
        return userInfoDao.getContestInfoByErpNoInSalary(erpNo, salaryId, mouldId, ruleId, year,orgId,businessTypeId);
    }


    @Override
    public List<TecInnovInfoVo> getTecInnovInfoByErpNo(String erpNo, String salaryId, String mouldId, String ruleId, int year,String orgId) {
        return userInfoDao.getTecInnovInfoByErpNo(erpNo, salaryId, mouldId, ruleId, year,orgId);
    }

    @Override
    public List<TecInnovInfoVo> getTecInnovInfoByErpNoInSalary(String erpNo, String salaryId, String mouldId, String ruleId, int year,String orgId,String businessTypeId) {
        return userInfoDao.getTecInnovInfoByErpNoInSalary(erpNo, salaryId, mouldId, ruleId, year,orgId,businessTypeId);
    }


    @Override
    public List<TecManInnovVo> getTecManInnovByErpNo(String erpNo, String salaryId, String mouldId,
                                                     String ruleId, int year,String orgId) {
        return userInfoDao.getTecManInnovByErpNo(erpNo, salaryId, mouldId, ruleId, year,orgId);
    }

    @Override
    public List<TecManInnovVo> getTecManInnovByErpNoInSalary(String erpNo, String salaryId, String mouldId,
                                                     String ruleId, int year,String orgId,String businessTypeId) {
        return userInfoDao.getTecManInnovByErpNoInSalary(erpNo, salaryId, mouldId, ruleId, year,orgId,businessTypeId);
    }


    /**
     * 获取积分详情
     *
     * @param ruleId
     * @param mouId
     * @return
     */
    @Override
    public List<TRuleElementInfo> getTRuleElementInfoByproIdAndMouId(String ruleId, String mouId,String orgId) {
        return userInfoDao.getTRuleElementInfoByproIdAndMouId(ruleId, mouId,orgId);
    }


    /**
     * 员工流动
     */
	@Override
	public List<TEmployeeMobilityVo> getEmployeeMobilityByErpNo(String erpNo, String salaryId, String mouldId,
			String ruleId, int year, String baseOrgId) {
		return userInfoDao.getEmployeeMobilityByErpNo(erpNo,salaryId,mouldId,ruleId,year,baseOrgId);
	}

    @Override
    public List<TEmployeeMobilityVo> getEmployeeMobilityByErpNoInSalary(String erpNo, String salaryId, String mouldId,
                                                                String ruleId, int year, String baseOrgId,String businessTypeId) {
        return userInfoDao.getEmployeeMobilityByErpNoInSalary(erpNo,salaryId,mouldId,ruleId,year,baseOrgId,businessTypeId);
    }

    /**
     * 技术标准
     */
    @Override
    public List<TecStandardVo> getTecStandardInfoByErpNo(String erpNo,String salaryId,String mouldId,String ruleId,int year,String orgId){
        return userInfoDao.getTecStandardInfoByErpNo(erpNo,salaryId,mouldId,ruleId,year,orgId);
    }

    @Override
    public List<TecStandardVo> getTecStandardInfoByErpNoInSalary(String erpNo,String salaryId,String mouldId,String ruleId,int year,String orgId,String businessTypeId){
        return userInfoDao.getTecStandardInfoByErpNoInSalary(erpNo,salaryId,mouldId,ruleId,year,orgId,businessTypeId);
    }
}
